package com.typedef.helper;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import android.util.Log;

public class HelperContainer {
	// http://docs.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/ConcurrentHashMap.html
	static private Map<String,Object> objectMap = new ConcurrentHashMap<String,Object>();
	static private final String TAG = HelperContainer.class.getSimpleName();
	static public final String USB_CONN_HELPER = "USB_CONN_HELPER";
	
	static public synchronized Object setObject(String key, Object obj){
		if(key.isEmpty() || obj == null){
			Log.i(TAG, "Key or object null.");
			return null;
		}
		
		objectMap.put(key, obj);
		return obj;
	}
	
	static public synchronized Object getObject(String key){
		if(objectMap == null || objectMap.size() <= 0){
			Log.i(TAG, "Object map null or size of object map <= 0.");
			return null;
		}
		if(key == null || key.isEmpty()){
			Log.i(TAG, "Key null or empty.");
			return null;
		}
		return objectMap.get(key);
	}
}
